package com.ow.dva.module.base.controller;

import com.ow.dva.module.base.entity.json.RT;
import com.ow.dva.module.base.service.KafkaService;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping(value = "/kafka")
@Api(tags = "Kafka 消息中间件")
public class KafkaController {


    /**
     * 发送消息到指定topic
     * @param topic
     * @param message
     * @return
     */
    @PostMapping(value="/sendStr")
    @ResponseBody
    public RT sendStr(String topic,String message){
        kafkaService.sendMessage(topic,message);
        return RT.ok();
    }

    @Resource
    private KafkaService kafkaService;
}
